/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Animation.Animations;

import Scenery.BaseSprite;
import main.DumbMath;
import com.jme3.math.Matrix3f;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import Animation.Animation;
import Animation.Animation;
import Scenery.BaseCharacter;
import Scenery.BaseSprite;
import java.awt.Frame;
import main.DumbMath;

/*
 * 
 * @author: Ziden
 * 
 */

public class ChestBounce extends Animation {

    public ChestBounce(BaseCharacter dude) {
        super(dude, 20);
        buildAnimation();
    }
    protected Vector3f chest;

    public void performFrame() {
        animationBody.getBodyNode().setLocalTranslation(animationBody.getBodyNode().getLocalTranslation().add(new Vector3f(0f, animationFrames[frame][0], 0f)));
    }

    protected float chestY = 0f;
    protected float chestSpeed = 0.025f;
    
    @Override
    protected void buildFrame() {
           if(frame  < maxFrame/4)
               chestY = chestSpeed;
           else if(frame >= maxFrame/4 && frame < (maxFrame*3)/4)
               chestY = -chestSpeed;
           else if(frame >= (maxFrame*3)/4)
               chestY = chestSpeed;
           animationFrames[frame][0] = chestY;
    }

    @Override
    public void gotoInitialState() {
        animationBody.getBodyNode().setLocalTranslation(chest);
        chestY = 0f;
        cicle = 0;
        chestSpeed =  0.025f;
        frame = 0;

    }

    @Override
    public String getName() {
        return "ChestBounce";
    }

    @Override
    public void saveInitialState() {
        chest = animationBody.getBodyNode().getLocalTranslation().clone();
    }

    @Override
    protected float getCicleRunTime() {
       return 0f;
    }
}
